import Vue from 'vue';
import Router from 'vue-router';
import Login from '@/components/Login';
import Activity from '@/components/Activity';
import ActivityList from '@/components/ActivityList';
import Join from '@/components/Join';
import JoinList from '@/components/JoinList';
import Diamond from '@/components/Diamond';

Vue.use(Router);
const router = new Router({
  routes: [{
    path: '/',
    name: 'Login',
    component: Login
  }, {
    path: '/activity',
    name: 'Activity',
    component: Activity
  }, {
    path: '/activityList',
    name: 'ActivityList',
    component: ActivityList
  }, {
    path: '/join',
    name: 'Join',
    component: Join
  }, {
    path: '/joinList',
    name: 'JoinList',
    component: JoinList
  }, {
    path: '/diamond',
    name: 'Diamond',
    component: Diamond
  }]
});

router.beforeEach((to, from, next) => {
  const toDepth = to.path.split('/').length
  const fromDepth = from.path.split('/').length
  if (toDepth < fromDepth) {
    console.log('后退。。。')
    from.meta.keepAlive = false
    to.meta.keepAlive = true
  }
  next()
})


export default router
